﻿{include file="public/header" /} 
<title>用户组规则</title>
</head>
<body>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户组管理 <span class="c-gray en">&gt;</span> 权限分配 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<article class="page-container">
		<h4 class="text-center" style="margin-left: 320px;">为<span style="color:red;">{$group['title']}</span>分配权限</h4>
	<form action="{:url('admin/rule/rule_group')}" method="post" class="form form-horizontal" id="form-admin-role-add">
		<input type="hidden" name="id" id="id" value="{$group['id']}" />
		
		<div class="row cl role">
			<label class="form-label col-xs-4 col-sm-3">权限列表：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{foreach name="rule" item="v"}
				<dl class="permission-list">
				  {empty name="v['_data']"}
					<dt>
						<label>
							<input type="checkbox"  name="rules_id[]" id="user-Character-0" value="{$v['id']}" {if condition="(in_array($v['id'],$group['rules']))"} checked {/if}>
							{$v['title']}</label>
					</dt>
				  {else /}
					<dt>
						<label>
							<input type="checkbox"name="rules_id[]"  value="{$v['id']}"  id="user-Character-0" {if condition="(in_array($v['id'],$group['rules']))"} checked {/if}>
							{$v['title']}</label>
					</dt>
					<dd>
						{foreach name="v['_data']" item="n"}
						<dl class="cl permission-list2">
							<dt>
								<label class="">
									<input type="checkbox"  name="rules_id[]" value="{$n['id']}" id="user-Character-0-0" {if condition="(in_array($n['id'],$group['rules']))"} checked {/if}>
									{$n['title']}</label>
							</dt>
							{notempty name="n['_data']"}
							<dd>
								{volist name="n['_data']" id="c"}
								<label class="">
									<input type="checkbox" name="rules_id[]"  value="{$c['id']}" id="user-Character-0-0-0" {if condition="(in_array($c['id'],$group['rules']))"} checked {/if}>
									{$c['title']}</label>
								{/volist}
								
							</dd>
							{/notempty}
						</dl>
						{/foreach}
					
					</dd>
				   {/empty}
				</dl>
				{/foreach}
				
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-success radius" id="admin-role-save" name="" style="margin-left: 160px;"><i class="icon-ok"></i> 确定</button>
			</div>
		</div>
	</form>
</article>

{include file="public/footer" /} 

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
$(function(){
	$(".permission-list dt input:checkbox").click(function(){
		$(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
	});
	$(".permission-list2 dd input:checkbox").click(function(){
		var l =$(this).parent().parent().find("input:checked").length;
		var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
		if($(this).prop("checked")){
			$(this).closest("dl").find("dt input:checkbox").prop("checked",true);
			$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
		}
		else{
			if(l==0){
				$(this).closest("dl").find("dt input:checkbox").prop("checked",false);
			}
			if(l2==0){
				$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
			}
		}
	});
	
//	$("#form-admin-role-add").validate({
//		rules_id:{
//			roleName:{
//				required:true,
//			},
//		},
//		onkeyup:false,
//		focusCleanup:true,
//		success:"valid",
//		submitHandler:function(form){
//			$(form).ajaxSubmit();
//			var index = parent.layer.getFrameIndex(window.name);
//			parent.layer.close(index);
//		}
//	});
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>